using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class UI_StatToolTip : UI_ToolTip
{
    [SerializeField] private TextMeshProUGUI statDescription;

    private Player_Stats playerStats;

    protected override void Awake()
    {
        base.Awake();
        playerStats = FindAnyObjectByType<Player_Stats>();
    }
    public void ShowToolTip(bool isShow, RectTransform targetRect, StatType type)
    {
        base.ShowToolTip(isShow, targetRect);
        statDescription.text = GetStatDescriptionByType(type);
    }

    private string GetStatDescriptionByType(StatType type)
    {
        return type switch
        {
            //Major Attributes
            StatType.Strength => "Increases physical damage by 1 per point." +
                                "\n Increases critical power by 0.5% per point.",
            StatType.Agility => "Increases critical chance by 0.3% per point." +
                                "\n Increases evasion by 0.5% per point.",
            StatType.Intelligence => "Increases elemental damage by 0.5% per point." +
                                "\n add 1 elemental damage per point as a bonus." +
                                "\n If all elementals have 0 damage, the bonus will not be applied.",
            StatType.Vitality => "Increases maximun health by 5 per point." +
                                "\n Increases armor by 1 per point.",

            //Physical Dmage
            StatType.Damage => "Determines the physical damage of your attacks.",
            StatType.CritChance => "Chance for your attacks to critically strike.",
            StatType.CritPower => "Increases the damage dealt by critical strikes.",
            StatType.ArmorReduction => "Percent of armor that will be ignored by your attacks.",
            StatType.AttackSpeed => "Determines how quickly you can attack.",

            //Defense
            StatType.MaxHealth => "Determines how much total health you have.",
            StatType.HealthRegen => "Amount of health restored per second",
            StatType.Armor => "Reduces incoming physical damage."
                            + "\nArmor mitigation is Limited at 85%"
                            + "\nCurrent mitigation is: " + playerStats.GetArmorMitigation(0) * 100 + "%. ",
            StatType.Evasion => "Chance to completely avoid attacks." + "\n limited at 85%",
            //Elemental Damage
            StatType.IceDamage => "Determines the ice damage of your attacks. ",
            StatType.FireDamage => "Determines the fire damage of your attacks. ",
            StatType.LightningDamage => "Determines the lightning damage of your attacks. ",
            StatType.ElementalDamage => "Elemetnal damage combines all three elements" +
                                        "\n The hightest element applies corresponding element status effect and full damage. " +
                                        "\n The other two elements contribute 50% of their damage as a bonus. ",

            //Elemental Resistances
            StatType.IceResistance => "Reduces ice damage taken. ",
            StatType.FireResistance => "Reduces fire damage taken. ",
            StatType.LightningResistance => "Reduces lightning damage taken. ",

            _ => "No Description"

        };
    }
    
}
